#import "file_config_comic.h"

CGPoint g_CfgComicPage1Position[7];
CGPoint g_CfgComicPage2Position[6];
CGPoint g_CfgComicPage3Position[5];
CGPoint g_CfgComicPage4Position[7];
CGPoint g_CfgComicPage5Position[4];
CGPoint g_CfgComicPage6Position[4];
CGPoint g_CfgComicPage7Position[4];

void CfgComicLoadConfigFile(void)
{
	int i;
	char _Buffer[256];
	FILE *_ConfigFile;
	mxml_node_t *_NodeXml, *_NodeBouy, *_NodePage;

	memset(_Buffer, 0, sizeof _Buffer);
	[[CCFileUtils fullPathFromRelativePath:@"file_config_comic.xml"] getCString:_Buffer maxLength:sizeof _Buffer encoding:NSASCIIStringEncoding];
	_ConfigFile = fopen(_Buffer, "r");
	if (NULL != _ConfigFile)
	{
		_NodeXml = mxmlLoadFile(NULL, _ConfigFile, MXML_TEXT_CALLBACK);
		_NodeBouy = mxmlGetFirstChild(_NodeXml);
		for (; NULL != _NodeBouy; _NodeBouy = mxmlWalkNext(_NodeBouy, _NodeXml, MXML_NO_DESCEND))
		{
			if (tmxmlIsElement(_NodeBouy, "page_1"))
			{
				_NodePage = mxmlGetFirstChild(_NodeBouy);
				for (i = 0; NULL != _NodePage; _NodePage = mxmlWalkNext(_NodePage, _NodeBouy, MXML_NO_DESCEND))
				{
					if (tmxmlIsElement(_NodePage, "position"))
					{
						uiLoadPointFromXML(_NodePage, &g_CfgComicPage1Position[i++]);
					}
				}
			}
			else if (tmxmlIsElement(_NodeBouy, "page_2"))
			{
				_NodePage = mxmlGetFirstChild(_NodeBouy);
				for (i = 0; NULL != _NodePage; _NodePage = mxmlWalkNext(_NodePage, _NodeBouy, MXML_NO_DESCEND))
				{
					if (tmxmlIsElement(_NodePage, "position"))
					{
						uiLoadPointFromXML(_NodePage, &g_CfgComicPage2Position[i++]);
					}
				}
			}
			else if (tmxmlIsElement(_NodeBouy, "page_3"))
			{
				_NodePage = mxmlGetFirstChild(_NodeBouy);
				for (i = 0; NULL != _NodePage; _NodePage = mxmlWalkNext(_NodePage, _NodeBouy, MXML_NO_DESCEND))
				{
					if (tmxmlIsElement(_NodePage, "position"))
					{
						uiLoadPointFromXML(_NodePage, &g_CfgComicPage3Position[i++]);
					}
				}
			}
			else if (tmxmlIsElement(_NodeBouy, "page_4"))
			{
				_NodePage = mxmlGetFirstChild(_NodeBouy);
				for (i = 0; NULL != _NodePage; _NodePage = mxmlWalkNext(_NodePage, _NodeBouy, MXML_NO_DESCEND))
				{
					if (tmxmlIsElement(_NodePage, "position"))
					{
						uiLoadPointFromXML(_NodePage, &g_CfgComicPage4Position[i++]);
					}
				}
			}
			else if (tmxmlIsElement(_NodeBouy, "page_5"))
			{
				_NodePage = mxmlGetFirstChild(_NodeBouy);
				for (i = 0; NULL != _NodePage; _NodePage = mxmlWalkNext(_NodePage, _NodeBouy, MXML_NO_DESCEND))
				{
					if (tmxmlIsElement(_NodePage, "position"))
					{
						uiLoadPointFromXML(_NodePage, &g_CfgComicPage5Position[i++]);
					}
				}
			}
			else if (tmxmlIsElement(_NodeBouy, "page_6"))
			{
				_NodePage = mxmlGetFirstChild(_NodeBouy);
				for (i = 0; NULL != _NodePage; _NodePage = mxmlWalkNext(_NodePage, _NodeBouy, MXML_NO_DESCEND))
				{
					if (tmxmlIsElement(_NodePage, "position"))
					{
						uiLoadPointFromXML(_NodePage, &g_CfgComicPage6Position[i++]);
					}
				}
			}
			else if (tmxmlIsElement(_NodeBouy, "page_7"))
			{
				_NodePage = mxmlGetFirstChild(_NodeBouy);
				for (i = 0; NULL != _NodePage; _NodePage = mxmlWalkNext(_NodePage, _NodeBouy, MXML_NO_DESCEND))
				{
					if (tmxmlIsElement(_NodePage, "position"))
					{
						uiLoadPointFromXML(_NodePage, &g_CfgComicPage7Position[i++]);
					}
				}
			}
		}
	}
}